<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport"/>
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>我的钱包</title>
    <link rel="stylesheet" href="/index/css/common.css?v=2">
    <link rel="stylesheet" href="/index/css/wallet.css">

</head>
<body>
<div class="tabsBox">
    <div class="topTab">
        <div class="tabLeft">
            <img src="/index/assets/left.png">
        </div>
        <div class="tabCenters">我的钱包</div>
        <!-- <div class="tabRight">收益说明</div> -->
    </div>
</div>
<div class="wallet">
    <div class="tixian">
        <div class="tixianList cleardrift">
            <div class="keti">可提现余额: {$user.money}</div>
            <a class="tixianBtn" href="{:url('takeMoney')}">提现</a>
        </div>
        <div class="profit cleardrift">
            <div class="today">今日收益: {$today_earnings}</div>
            <div class="all">累计收益: {$user.total_earnings}</div>
        </div>
    </div>
    <div class="history">
        <div class="historyTitle">提现纪录</div>
        <div class="historyBox">
            <!--<div class="historyList">-->
                <!--<div class="listLeft">-->
                    <!--<div class="tixianState">提现申请</div>-->
                    <!--<div class="tixianTime">2019-09-12 12:11:12</div>-->
                <!--</div>-->
                <!--<div class="listRight">-->
                    <!--<div class="tixianMoney">¥1000</div>-->
                    <!--&lt;!&ndash;<div class="success">(成功)</div>&ndash;&gt;-->
                <!--</div>-->
            <!--</div>-->
            <!--</div>-->
        </div>
    </div>
    <p id="load-text" style="text-align: center;margin-top:10px;color:#aaa;"></p>
</div>
{include file='common/toast'}
</body>
<script type="text/javascript" src="/index/js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="/index/js/common.js"></script>

<script>
    $(function () {

        var page = 1
        var flag = 0;
        var is_end = 0
        getList();

        //获取邀请好友列表
        function getList() {

            if (flag == 1) {
                return;
            }

            flag = 1;

            $('#load-text').text('加载中...');
            $.get('{:url("takeMoneyRecord")}', {page: page}, function (res) {

                if (res.code == 0) {
                    toastFail(res.msg);
                    return;
                }
                var list = res.data.data;

                $('#load-text').text('');

                for (k in list) {

                    var _html = '<div class="historyList">';
                    _html += '<div class="listLeft">';

                    switch(list[k].status){
                        case 0:
                            _html += '<div class="tixianState" >（审核中）</div>';

                            break;
                        case 1:
                            _html += '<div class="tixianState" style="color:#7cd33b">（成功）</div>';

                            break;
                        case 2:
                            _html += '<div class="tixianState" style="color:#ffc700">（失败）</div>';

                            break;
                    }
                    _html += ' <div class="tixianTime">'+list[k].create_time+'</div>';

                    _html += '</div>';
                    _html += '<div class="listRight">';
                    _html += ' <div class="tixianMoney">¥'+list[k].money+'</div>';
                    _html += '  </div>';
                    _html += ' </div>';

                    $(".historyBox").append(_html);

                }

                if (res.data.last_page == 0) {
                    is_end = 1;

                    $('#load-text').text('暂无提现记录');
                    $('#load-text').css('margin-top', '20%')
                    return;
                }

                if (res.data.current_page >= res.data.last_page) {
                    is_end = 1;
                    $('#load-text').text('已加载全部');

                    return;
                }

                page++;
                flag = 0;

            }, 'json')
        }


        $(window).scroll(function () {

            if (is_end == 0) {

                //当时滚动条离底部60px时开始加载下一页的内容
                if (($(window).height() + $(window).scrollTop() + 60) >= $(document).height()) {

                    getList();
                }
            }

        });
    })
</script>
</html>